from flask import Flask, jsonify
from flask_cors import CORS

from util import util

app = Flask(__name__)
CORS(app)

tasks = [
    {
        'id': 1,
        'title': 'Learn Python',
        'description': 'Learn Python programming language',
        'done': False
    },
    {
        'id': 2,
        'title': 'Buy Groceries',
        'description': 'Buy groceries for the week',
        'done': False
    }
]

# restful api
# get (query, select), put (update), post (insert), delete (delete)


@app.route("/api/class")
def getClass():
    rst = util.execute_query('select * from edu_class where class_id = 1;')
    return jsonify(rst)


@app.route('/api/tasks', methods=['GET'])
def get_tasks():
    return jsonify({'tasks': tasks})


if __name__ == '__main__':
    app.run(debug=True)
